import axios from "axios"
const http = axios.create({
    baseURL:"http://127.0.0.1:8080/api",
    timeout: 30000,
    headers: {
        "Content-Type":"application/json",

    }
})

http.interceptors.request.use((config)=>{
    config.headers.userToken = "admin1234";
    return config;
},(error)=>{
    return Promise.reject(error)
})

http.interceptors.response.use((response)=>{
    if(response.data.code == 200){
        return response.data.data;
    }else{
        return Promise.reject(response.data.msg);
    }
}, (error)=>{
    return Promise.reject(new Error(error.message))
})


export default http